/*
 * Copyright (c) 2022-2023 cetcclout Co., Ltd All rights reserved.
 * Sensor Adapter is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package com.cetccloud.cimp.common.util;
import cn.hutool.json.JSONUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExhaustGasCreator {

	private static final Logger log = LoggerFactory.getLogger(ExhaustGasCreator.class);
    /**
     * @apiNote 生成实时数据
     * @param deviceId
     * @param dataBlock
     * @param randomData
     */
    public static void createExhaustGasRtdData(String deviceId, StringBuilder dataBlock, Map<String, Object> randomData) {
        /**
         * 二氧化硫实时浓度(mg/m3)     a21026-Rtd 1
         * 二氧化硫实时折算浓度(mg/m3)  a21026-ZsRtd 2
         * 氮氧化物实时浓度(mg/m3)     a21002-Rtd 3
         * 氮氧化物实时折算浓度(mg/m3)  a21002-ZsRtd 4
         * 烟尘实时浓度(mg/m3)         a34013-Rtd 5
         * 烟尘实时折算浓度(mg/m3)      a34013-ZsRtd 6
         * 二氧化硫实时排放速率(kg/h)   c05121-Rtd 7
         * 氮氧化物实时排放速率(kg/h)   c05122-Rtd 8
         * 烟尘实时排放速率(kg/h)      c05123-Rtd 9
         * 二氧化硫排放量(kg)         c05125-Rtd 10
         * 氮氧化物排放量(kg)         c05126-Rtd 11
         * 烟尘排放量(kg)            c05127-Rtd 12
         *
         * VOCs实时浓度(mg/m3)       a24088-Rtd 13
         * VOCs实时折算浓度(mg/m3)    a24088-ZsRtd 14
         *
         * VOCs实时排放速率(kg/h)    c05124-Rtd    16
         * VOCs排放量(kg)           c05128-Rtd    16
         *
         */
        //二氧化硫实时浓度(mg/m3)     a21026-Rtd 二氧化硫实时折算浓度(mg/m3)  a21026-ZsRtd
        dataBlock.append("a21026-Rtd="+ getCellValue(randomData.get("二氧化硫实时浓度(mg/m3)")) +",a21026-ZsRtd="+ getCellValue(randomData.get("二氧化硫实时折算浓度(mg/m3)"))+",a21026-Flag=N;");
        //二氧化硫实时折算浓度(mg/m3)  a21026-ZsRtd
        //氮氧化物实时浓度(mg/m3)  a21002-Rtd 氮氧化物实时折算浓度(mg/m3)  a21002-ZsRtd
        dataBlock.append("a21002-Rtd="+ getCellValue(randomData.get("氮氧化物实时浓度(mg/m3)")) +",a21002-ZsRtd="+getCellValue(randomData.get("氮氧化物实时折算浓度(mg/m3)"))+",a21002-Flag=N;");
        //烟尘实时浓度(mg/m3)         a34013-Rtd 烟尘实时折算浓度(mg/m3)      a34013-ZsRtd
        dataBlock.append("a34013-Rtd="+ getCellValue(randomData.get("烟尘实时浓度(mg/m3)")) +",a34013-ZsRtd="+getCellValue(randomData.get("烟尘实时折算浓度(mg/m3)")) +",a34013-Flag=N;");

        //VOCs实时浓度(mg/m3)       a24088-Rtd   VOCs实时折算浓度(mg/m3)    a24088-ZsRtd new
        dataBlock.append("a24088-Rtd="+ getCellValue(randomData.get("VOCs实时浓度(mg/m3)")) +",a24088-ZsRtd="+getCellValue(randomData.get("VOCs实时折算浓度(mg/m3)")) +",a24088-Flag=N;");

        //二氧化硫实时排放速率(kg/h)   c05121-Rtd
        dataBlock.append("c05121-Rtd="+ getCellValue(randomData.get("二氧化硫实时排放速率(kg/h)")) +",c05121-Flag=N;");
        //氮氧化物实时排放速率(kg/h)   c05122-Rtd
        dataBlock.append("c05122-Rtd="+ getCellValue(randomData.get("氮氧化物实时排放速率(kg/h)")) +",c05122-Flag=N;");
        //烟尘实时排放速率(kg/h)      c05123-Rtd
        dataBlock.append("c05123-Rtd="+ getCellValue(randomData.get("烟尘实时排放速率(kg/h)")) +",c05123-Flag=N;");
        //二氧化硫排放量(kg)         c05125-Rtd
        dataBlock.append("c05125-Rtd="+ getCellValue(randomData.get("二氧化硫排放量(kg)")) +",c05125-Flag=N;");
        //氮氧化物排放量(kg)         c05126-Rtd
        dataBlock.append("c05126-Rtd="+ getCellValue(randomData.get("氮氧化物排放量(kg)")) +",c05126-Flag=N;");

        //VOCs实时排放速率(kg/h)    c05124-Rtd
        dataBlock.append("c05124-Rtd="+ getCellValue(randomData.get("VOCs实时排放速率(kg/h)")) +",c05124-Flag=N;");
        //VOCs排放量(kg)           c05128-Rtd
        dataBlock.append("c05128-Rtd="+ getCellValue(randomData.get("VOCs排放量(kg)")) +",c05128-Flag=N;");

        //烟尘排放量(kg)            c05127-Rtd
        dataBlock.append("c05127-Rtd="+ getCellValue(randomData.get("烟尘排放量(kg)")) +",c05127-Flag=N");

        //========================
        List<Double> a21026Rtd = DataConfig.MINUTE_DATA.get(deviceId,"a21026-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"a21026-Rtd");
        a21026Rtd.add(Double.valueOf(getCellValue(randomData.get("二氧化硫实时浓度(mg/m3)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "a21026-Rtd", a21026Rtd);

        List<Double> a21026ZsRtd = DataConfig.MINUTE_DATA.get(deviceId,"a21026-ZsRtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"a21026-ZsRtd");
        a21026ZsRtd.add(Double.valueOf(getCellValue(randomData.get("二氧化硫实时折算浓度(mg/m3)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "a21026-ZsRtd", a21026ZsRtd);

        List<Double> a21002Rtd = DataConfig.MINUTE_DATA.get(deviceId,"a21002-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"a21002-Rtd");
        a21002Rtd.add(Double.valueOf(getCellValue(randomData.get("氮氧化物实时浓度(mg/m3)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "a21002-Rtd", a21002Rtd);

        List<Double> a21002ZsRtd = DataConfig.MINUTE_DATA.get(deviceId,"a21002-ZsRtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"a21002-ZsRtd");
        a21002ZsRtd.add(Double.valueOf(getCellValue(randomData.get("氮氧化物实时折算浓度(mg/m3)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "a21002-ZsRtd", a21002ZsRtd);

        List<Double> a34013Rtd = DataConfig.MINUTE_DATA.get(deviceId,"a34013-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"a34013-Rtd");
        a34013Rtd.add(Double.valueOf(getCellValue(randomData.get("烟尘实时浓度(mg/m3)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "a34013-Rtd", a34013Rtd);

        List<Double> a34013ZsRtd = DataConfig.MINUTE_DATA.get(deviceId,"a34013-ZsRtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"a34013-ZsRtd");
        a34013ZsRtd.add(Double.valueOf(getCellValue(randomData.get("烟尘实时折算浓度(mg/m3)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "a34013-ZsRtd", a34013ZsRtd);


        List<Double> a24088Rtd = DataConfig.MINUTE_DATA.get(deviceId,"a24088-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"a24088-Rtd");
        a24088Rtd.add(Double.valueOf(getCellValue(randomData.get("VOCs实时浓度(mg/m3)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "a24088-Rtd", a24088Rtd);

        List<Double> a24088ZsRtd = DataConfig.MINUTE_DATA.get(deviceId,"a24088-ZsRtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"a24088-ZsRtd");
        a24088ZsRtd.add(Double.valueOf(getCellValue(randomData.get("VOCs实时折算浓度(mg/m3)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "a24088-ZsRtd", a24088ZsRtd);

        List<Double> c05121Rtd = DataConfig.MINUTE_DATA.get(deviceId,"c05121-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"c05121-Rtd");
        c05121Rtd.add(Double.valueOf(getCellValue(randomData.get("二氧化硫实时排放速率(kg/h)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "c05121-Rtd", c05121Rtd);

        List<Double> c05122Rtd = DataConfig.MINUTE_DATA.get(deviceId,"c05122-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"c05122-Rtd");
        c05122Rtd.add(Double.valueOf(getCellValue(randomData.get("氮氧化物实时排放速率(kg/h)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "c05122-Rtd", c05122Rtd);

        List<Double> c05123Rtd = DataConfig.MINUTE_DATA.get(deviceId,"c05123-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"c05123-Rtd");
        c05123Rtd.add(Double.valueOf(getCellValue(randomData.get("烟尘实时排放速率(kg/h)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "c05123-Rtd", c05123Rtd);

        List<Double> c05125Rtd = DataConfig.MINUTE_DATA.get(deviceId,"c05125-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"c05125-Rtd");
        c05125Rtd.add(Double.valueOf(getCellValue(randomData.get("二氧化硫排放量(kg)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "c05125-Rtd", c05125Rtd);

        List<Double> c05126Rtd = DataConfig.MINUTE_DATA.get(deviceId,"c05126-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"c05126-Rtd");
        c05126Rtd.add(Double.valueOf(getCellValue(randomData.get("氮氧化物排放量(kg)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "c05126-Rtd", c05126Rtd);

        List<Double> c05127Rtd = DataConfig.MINUTE_DATA.get(deviceId,"c05127-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"c05127-Rtd");
        c05127Rtd.add(Double.valueOf(getCellValue(randomData.get("烟尘排放量(kg)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "c05127-Rtd", c05127Rtd);

        List<Double> c05124Rtd = DataConfig.MINUTE_DATA.get(deviceId,"c05124-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"c05124-Rtd");
        c05124Rtd.add(Double.valueOf(getCellValue(randomData.get("VOCs实时排放速率(kg/h)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "c05124-Rtd", c05124Rtd);

        List<Double> c05128Rtd = DataConfig.MINUTE_DATA.get(deviceId,"c05128-Rtd")==null?new ArrayList<>():DataConfig.MINUTE_DATA.get(deviceId,"c05128-Rtd");
        c05128Rtd.add(Double.valueOf(getCellValue(randomData.get("VOCs排放量(kg)").toString())));
        DataConfig.MINUTE_DATA.put(deviceId, "c05128-Rtd", c05128Rtd);



    }

    /**
     * 		a21026-Rtd
     * 		a21026-ZsRtd
     * 		a21002-Rtd
     * 		a21002-ZsRtd
     * 		a34013-Rtd
     * 		a34013-ZsRtd
     * 		c05121-Rtd
     * 		c05122-Rtd
     * 		c05123-Rtd
     * 		c05125-Rtd
     * 		c05126-Rtd
     * 		c05127-Rtd
     * @param deviceId
     * @param dataBlock
     */
    public static void createExhaustGasMinuteData(String deviceId, StringBuilder dataBlock){
        //a21026-Rtd  a21026-ZsRtd
        dataBlock.append(getDataMinuteGasTwo(deviceId,"a21026"));
        //a21002-Rtd  a21002-ZsRtd
        dataBlock.append(getDataMinuteGasTwo(deviceId,"a21002"));
        //a34013-Rtd  a34013-ZsRtd
        dataBlock.append(getDataMinuteGasTwo(deviceId,"a34013"));
        //a24088-Rtd a24088-ZsRtd new
        dataBlock.append(getDataMinuteGasTwo(deviceId,"a24088"));

        dataBlock.append(getDataMinuteGas(deviceId,"c05121-Rtd"));
        dataBlock.append(getDataMinuteGas(deviceId,"c05122-Rtd"));
        dataBlock.append(getDataMinuteGas(deviceId,"c05123-Rtd"));
        dataBlock.append(getDataMinuteGas(deviceId,"c05125-Rtd"));
        dataBlock.append(getDataMinuteGas(deviceId,"c05126-Rtd"));
        //new
        dataBlock.append(getDataMinuteGas(deviceId,"c05124-Rtd"));
        dataBlock.append(getDataMinuteGas(deviceId,"c05128-Rtd"));

        dataBlock.append(getDataMinuteGas(deviceId,"c05127-Rtd").replace(";",""));
        //处理完毕数据后清空
        DataConfig.MINUTE_DATA.get(deviceId,"a21026-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"a21026-ZsRtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"a21002-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"a21002-ZsRtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"a34013-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"a34013-ZsRtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"c05121-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"c05122-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"c05123-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"c05125-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"c05126-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"c05127-Rtd").clear();

        DataConfig.MINUTE_DATA.get(deviceId,"c05124-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"c05128-Rtd").clear();

        DataConfig.MINUTE_DATA.get(deviceId,"a24088-Rtd").clear();
        DataConfig.MINUTE_DATA.get(deviceId,"a24088-ZsRtd").clear();


        log.info("十分钟数据：{}", JSONUtil.toJsonStr(DataConfig.MINUTE_DATA));
    }

    public static void createExhaustGasHourData(String deviceId, StringBuilder dataBlock){
        //a21026-Rtd  a21026-ZsRtd
        dataBlock.append(getDataHourGasTwo(deviceId,"a21026"));
        //a21002-Rtd  a21002-ZsRtd
        dataBlock.append(getDataHourGasTwo(deviceId,"a21002"));
        //a34013-Rtd  a34013-ZsRtd
        dataBlock.append(getDataHourGasTwo(deviceId,"a34013"));

        //a24088-Rtd a24088-ZsRtd new
        dataBlock.append(getDataHourGasTwo(deviceId,"a24088"));

        dataBlock.append(getDataHourGas(deviceId,"c05121-Rtd"));
        dataBlock.append(getDataHourGas(deviceId,"c05122-Rtd"));
        dataBlock.append(getDataHourGas(deviceId,"c05123-Rtd"));
        dataBlock.append(getDataHourGas(deviceId,"c05125-Rtd"));
        dataBlock.append(getDataHourGas(deviceId,"c05126-Rtd"));
        //new
        dataBlock.append(getDataHourGas(deviceId,"c05124-Rtd"));
        dataBlock.append(getDataHourGas(deviceId,"c05128-Rtd"));

        dataBlock.append(getDataHourGas(deviceId,"c05127-Rtd").replace(";",""));
        //处理完毕数据后清空
        DataConfig.HOUR_DATA.get(deviceId,"a21026-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"a21026-ZsRtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"a21002-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"a21002-ZsRtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"a34013-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"a34013-ZsRtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"c05121-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"c05122-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"c05123-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"c05125-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"c05126-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"c05127-Rtd").clear();

        DataConfig.HOUR_DATA.get(deviceId,"a24088-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"a24088-ZsRtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"c05124-Rtd").clear();
        DataConfig.HOUR_DATA.get(deviceId,"c05128-Rtd").clear();

        log.info("小时数据：{}",JSONUtil.toJsonStr(DataConfig.HOUR_DATA));
    }

    /**
     * 生成需要的十分钟模拟数据
     * @param deviceId
     * @param ID
     * @return
     */
    public static String getDataMinuteGas(String deviceId, String ID){

        List<Double> rtdDataList = DataConfig.MINUTE_DATA.get(deviceId,ID);

        List<Double> hourData = DataConfig.HOUR_DATA.get(deviceId,ID)==null?new ArrayList<>():DataConfig.HOUR_DATA.get(deviceId,ID);
        hourData.addAll(rtdDataList);
        DataConfig.HOUR_DATA.put(deviceId,ID,hourData);
        //得到和
        double cou = rtdDataList.stream().mapToDouble( Double :: valueOf ).sum();
        //得到平均数
        double avg = rtdDataList.stream().mapToDouble( Double :: valueOf ).average().getAsDouble();
        //得到最小值
        double min = rtdDataList.stream().mapToDouble( Double :: valueOf ).min().getAsDouble();
        //得到最大值
        double max = rtdDataList.stream().mapToDouble( Double :: valueOf ).max().getAsDouble();
        String finalId = ID.replace("-Rtd","");
        String data = finalId+"-Cou="+getValue(cou) +","+ finalId +"-Min="+ getValue(min) +","+ finalId +"-Avg="+ getValue(avg) +","+ finalId +"-Max="+ getValue(max) +";";
        return data;
    }

    /**
     *
     * @param deviceId
     * @param id
     * @return
     */
    public static String getDataMinuteGasTwo(String deviceId, String id){

        //a21026-Rtd  a21026-ZsRtd

        String idRtd = id+"-Rtd";
        String idZsRtd = id+"-ZsRtd";

        List<Double> rtdDataList = DataConfig.MINUTE_DATA.get(deviceId,idRtd);

        List<Double> rtdHourData = DataConfig.HOUR_DATA.get(deviceId,idRtd)==null?new ArrayList<>():DataConfig.HOUR_DATA.get(deviceId,idRtd);
        rtdHourData.addAll(rtdDataList);
        DataConfig.HOUR_DATA.put(deviceId,idRtd,rtdHourData);


        List<Double> zsRtdDataList = DataConfig.MINUTE_DATA.get(deviceId,idZsRtd);

        List<Double> zsRtdHourData = DataConfig.HOUR_DATA.get(deviceId,idZsRtd)==null?new ArrayList<>():DataConfig.HOUR_DATA.get(deviceId,idZsRtd);
        zsRtdHourData.addAll(zsRtdDataList);
        DataConfig.HOUR_DATA.put(deviceId,idZsRtd,zsRtdHourData);

        //得到和
        double cou = rtdDataList.stream().mapToDouble( Double :: valueOf ).sum();
        //得到平均数
        double avg = rtdDataList.stream().mapToDouble( Double :: valueOf ).average().getAsDouble();
        //得到最小值
        double min = rtdDataList.stream().mapToDouble( Double :: valueOf ).min().getAsDouble();
        //得到最大值
        double max = rtdDataList.stream().mapToDouble( Double :: valueOf ).max().getAsDouble();

        //得到平均数
        double zsAvg = zsRtdDataList.stream().mapToDouble( Double :: valueOf ).average().getAsDouble();
        //得到最小值
        double zsMin = zsRtdDataList.stream().mapToDouble( Double :: valueOf ).min().getAsDouble();
        //得到最大值
        double zsMax = zsRtdDataList.stream().mapToDouble( Double :: valueOf ).max().getAsDouble();

        String data = id+"-Cou="+ getValue(cou) +","+ id +"-Min="+ getValue(min) +","+ id +"-Avg="+ getValue(avg )+","+ id +"-Max="+ getValue(max) +",";
        //String zsData= id +"-ZsMin="+ getValue(zsMin) +","+ id +"-ZsAvg="+ getValue(zsAvg) +","+ id +"-ZsMax="+ getValue(zsMax) +";";
        String zsData= id +"-ZsAvg="+ getValue(zsAvg) +";";
        //String zsData= id +"-ZsAvg="+ zsAvg +";";

        return (data.concat(zsData));
    }

    /**
     * 生成需要的小时模拟数据
     * @param deviceId
     * @param ID
     * @return
     */
    public static String getDataHourGas(String deviceId, String ID){
        List<Double> rtdDataList = DataConfig.HOUR_DATA.get(deviceId,ID);
        //得到和
        double cou = rtdDataList.stream().mapToDouble( Double :: valueOf ).sum();
        //得到平均数
        double avg = rtdDataList.stream().mapToDouble( Double :: valueOf ).average().getAsDouble();
        //得到最小值
        double min = rtdDataList.stream().mapToDouble( Double :: valueOf ).min().getAsDouble();
        //得到最大值
        double max = rtdDataList.stream().mapToDouble( Double :: valueOf ).max().getAsDouble();
        String finalId = ID.replace("-Rtd","");
        String data = finalId+"-Cou="+ getValue(cou) +","+ finalId +"-Min="+  getValue(min) +","+ finalId +"-Avg="+  getValue(avg) +","+ finalId +"-Max="+  getValue(max) +";";
        return data;
    }

    public static String getDataHourGasTwo(String deviceId, String id){

        String idRtd = id+"-Rtd";
        String idZsRtd = id+"-ZsRtd";

        List<Double> rtdDataList = DataConfig.HOUR_DATA.get(deviceId,idRtd);
        //得到和
        double cou = rtdDataList.stream().mapToDouble( Double :: valueOf ).sum();
        //得到平均数
        double avg = rtdDataList.stream().mapToDouble( Double :: valueOf ).average().getAsDouble();
        //得到最小值
        double min = rtdDataList.stream().mapToDouble( Double :: valueOf ).min().getAsDouble();
        //得到最大值
        double max = rtdDataList.stream().mapToDouble( Double :: valueOf ).max().getAsDouble();


        List<Double> zsRtdDataList = DataConfig.HOUR_DATA.get(deviceId,idZsRtd);
        //得到平均数
        double zsAvg = zsRtdDataList.stream().mapToDouble( Double :: valueOf ).average().getAsDouble();
        //得到最小值
        double zsMin = zsRtdDataList.stream().mapToDouble( Double :: valueOf ).min().getAsDouble();
        //得到最大值
        double zsMax = zsRtdDataList.stream().mapToDouble( Double :: valueOf ).max().getAsDouble();

        String data = id+"-Cou="+ getValue(cou) +","+ id +"-Min="+ getValue(min) +","+ id +"-Avg="+ getValue(avg )+","+ id +"-Max="+ getValue(max) +",";
        //String zsData= id +"-ZsMin="+ getValue(zsMin) +","+ id +"-ZsAvg="+ getValue(zsAvg) +","+ id +"-ZsMax="+ getValue(zsMax) +";";
        String zsData= id +"-ZsAvg="+ getValue(zsAvg)  +";";
        return (data.concat(zsData));
    }
    private static String getValue(double value){
        String v = value+"";
        if(v.length()>4) {
            String data = String.format("%.3f", value);
            return data;
        }else{
            return  v;
        }
    }

    private static String getCellValue(Object value){
        String v = value.toString()+"";
        if(v.length()>4) {
            String data = String.format("%.3f", Double.valueOf(value.toString()));
            return data;
        }else{
            return  v;
        }
    }
}
